package my_IO;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class ObjectInput_my {
    public static void main(String[] args) {
        ObjectInputStream ois = null; // 定义一个ObjectInputStream类型的变量
        String path = "d:\\develop\\test\\test.txt";
        try {
            // 创建一个ObjectInputStream的对象,进行反序列化
            ois = new ObjectInputStream(new FileInputStream(path));
            Object obj = ois.readObject();
            if (obj != null) {
                Object_Person objectPerson = (Object_Person) obj;
                System.out.println("编号为：" + objectPerson.getId() + " 姓名为："
                        + objectPerson.getName() + "年龄为：" + objectPerson.getAge());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                ois.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

}
